Skip to content

Update cast to use shared zeroconf#35570

Merged
bdraco merged 3 commits intohome-assistant:devfrom
bdraco:cast_use_shared_zeroconf
May 15, 2020
Merged

Update cast to use shared zeroconf#35570
bdraco merged 3 commits intohome-assistant:devfrom
bdraco:cast_use_shared_zeroconf

Conversation

@bdraco
Copy link
Copy Markdown
Member

@bdraco bdraco commented May 13, 2020

Proposed change

This allows updating cast to use the shared zeroconf instance added in #35484

Requires home-assistant-libs/pychromecast#362

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example entry for configuration.yaml:

# Example configuration.yaml

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

@probot-home-assistant
Copy link
Copy Markdown

Hey there @emontnemery, mind taking a look at this pull request as its been labeled with a integration (cast) you are listed as a codeowner for? Thanks!
(message by CodeOwnersMention)

@bdraco bdraco marked this pull request as draft May 13, 2020 03:07
@bdraco bdraco force-pushed the cast_use_shared_zeroconf branch from 4f7739d to aabf738 Compare May 13, 2020 03:08
@bdraco bdraco changed the title Updated cast to use shared zeroconf Update cast to use shared zeroconf May 13, 2020
@bdraco bdraco added the waiting-for-upstream We're waiting for a change upstream label May 13, 2020
@bdraco bdraco marked this pull request as ready for review May 13, 2020 03:28
@bdraco
Copy link
Copy Markdown
Member Author

bdraco commented May 13, 2020

Verified google cast was still discovered and tested with cast.show_lovelace_view

@emontnemery
Copy link
Copy Markdown
Contributor

@bdraco I think this is basically fine. Two points though:

  • cast will now require HA's zeroconf to be enabled or it will fail to work.
    Does zeroconf need to be added as a dependency of cast?
    Will there be an error message if cast is enabled but zeroconf is disabled?
  • The cast integration is not only relying on zeroconf for device discovery, but also to keep track of IP address changes and speaker groups. Can the shared zeroconf instance be "messed" with by other components, e.g. restarted, cache flushed etc?

@bdraco
Copy link
Copy Markdown
Member Author

bdraco commented May 13, 2020

@bdraco I think this is basically fine. Two points though:

  • cast will now require HA's zeroconf to be enabled or it will fail to work.
    Does zeroconf need to be added as a dependency of cast?

Yes 🤦 on my part, I added it to after_dependencies

Will there be an error message if cast is enabled but zeroconf is disabled?

There will now :)

  • The cast integration is not only relying on zeroconf for device discovery, but also to keep track of IP address changes and speaker groups. Can the shared zeroconf instance be "messed" with by other components, e.g. restarted, cache flushed etc?

When doing the initial investigation I identified the following integrations using Zeroconf:

homekit - safe if close is guarded
zeroconf - safe
cast - safe if close is guarded
pyvizio - unchecked as its relaying on home assistant's discovery (don't plan on adding to the share)
libpurecool - unchecked as its relaying on home assistant's discovery (don't plan on adding to the share)
aioesphomeapi - momentary use only and than destroyed, not worth sharing
netdisco - safe if close is guarded (may add to the share, but might not be worth the effort at this point)

The big risk is having the Zeroconf instance closed. We have guarded against that in zeroconf/__init__.py:class HaZeroconf by blocking the close until Home Assistant stops.

Right now the only integrations using it are zeroconf and homekit and I know both of these are safe. I'm also working on an a PR for python-zeroconf to try to solve the problem where each browser is running its own thread as its ever growing performance issue as we add new integrations to zeroconf discovery.

@bdraco bdraco force-pushed the cast_use_shared_zeroconf branch from 2d93c02 to dc23af3 Compare May 13, 2020 17:23
@bdraco bdraco removed the waiting-for-upstream We're waiting for a change upstream label May 13, 2020
@bdraco bdraco merged commit 7e56f2c into home-assistant:dev May 15, 2020
@bdraco
Copy link
Copy Markdown
Member Author

bdraco commented May 15, 2020

@emontnemery Thanks for reviewing.

@lock lock Bot locked and limited conversation to collaborators May 20, 2020
@balloob balloob added this to the 0.110.4 milestone May 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants